import java.util.HashSet;
import java.util.Iterator;

/**
 * @License: (C) Copyright 2013-2022
 * @Contact: abcque@outlook.com
 * @IDE: IntelliJ IDEA
 * @Encoding: utf-8
 * @Project: st2214st2215
 * @Package: PACKAGE_NAME
 * @File: PersonTest.java
 * @Time: 2023/4/18 15:29
 * @Author: abcque
 * @Description:
 * @Modifier:
 * @ModifyDate:
 * @ModifyRemark:
 */
public class PersonTest {
    public static void main(String[] args) {
        HashSet<Person> set = new HashSet<>();

        Person p1 = new Person("abc", 18);
        Person p2 = new Person("abc", 24);
        Person p3 = new Person("def", 18);
        Person p4 = new Person("xy", 36);


        set.add(p1);
        set.add(p2);
        set.add(p3);
        set.add(p4);

        Iterator<Person> iterator = set.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        Person p5 = new Person("abc", 18);

        int code1 = p1.hashCode();
        int code5 = p5.hashCode();

        System.out.println("code1 = " + code1);
        System.out.println("code5 = " + code5);

        boolean b = p1.equals(p5);
        System.out.println("b = " + b);

        boolean status = set.add(p5);
        System.out.println("status = " + status);
    }
}
